package 输出和输入.zuoye;

import java.io.*;

public class zuoye2 {
    public static void main(String[] args) {
        FileInputStream fis=null;
        DataInputStream dis=null;
        FileOutputStream fos=null;
        DataOutputStream dos=null;
        try {
            fis=new FileInputStream("F:/star.jpg");
            fos=new FileOutputStream("G:/mypicture.jpg");
            int len=0;
            byte[]b=new byte[1024];
            dis=new DataInputStream(fis);
            dos=new DataOutputStream(fos);
            while ((len=dis.read(b))!=-1){
                dos.write(b);
            }
            dos.flush();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (dos!=null){
                try {
                    dos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (dis!=null){
                try {
                    dis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }

            }
            if (fos!=null){
                try {
                    fos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (fis!=null){
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
